<?php


namespace app\admin\controller\setting;

use app\admin\controller\AdminController;
use app\admin\service\setting\WebSetService;
use think\response\Json;

class WebSet extends AdminController
{
    /**
     * 获取基础信息
     * @return Json
     */
    public function getWebInfo()
    {
        $result = WebSetService::getWebInfo();
        return $this->data($result);
    }

    /**
     * 设置基础信息
     * @return Json
     */
    public function setWebInfo()
    {
        $params = $this->postData([
            ['name', ''],
            ['url', ''],
            ['web_logo', ''],
            ['web_favicon', ''],
            ['app_name', ''],
            ['app_logo', ''],
            ['pc_name', ''],
            ['pc_logo', ''],
            ['pc_favicon', ''],
            ['seo_keyword', ''],
            ['seo_desc', ''],
        ]);
        $result = WebSetService::setWebInfo($params);
        if(true === $result) {
            return $this->success([], '设置成功');
        } else {
            return $this->error(WebSetService::getError());
        }
    }

    /**
     * 获取备案信息
     * @return Json
     */
    public function getWebRecord()
    {
        $result = WebSetService::getWebRecord();
        return $this->data($result);
    }

    /**
     * 设置基础信息
     * @return Json
     */
    public function setWebRecord()
    {
        $params = $this->postData([
            ['record_no', ''],
            ['copyright', ''],
            ['icp', ''],
            ['icp_url', ''],
            ['pcp', ''],
            ['pcp_url', ''],
        ]);
        $result = WebSetService::setWebRecord($params);
        if(true === $result) {
            return $this->success([], '设置成功');
        } else {
            return $this->error(WebSetService::getError());
        }
    }

    /**
     * 获取地图信息
     * @return Json
     */
    public function getMapInfo()
    {
        $result = WebSetService::getMapInfo();
        return $this->data($result);
    }

    /**
     * 设置地图信息
     * @return Json
     */
    public function setMapInfo()
    {
        $params = $this->postData();
        $result = WebSetService::setMapInfo($params);
        if(true === $result) {
            return $this->success([], '设置成功');
        } else {
            return $this->error(WebSetService::getError());
        }
    }


    /**
     * 获取邮件信息
     * @return Json
     */
    public function getMailInfo()
    {
        $result = WebSetService::getMailInfo();
        return $this->data($result);
    }

    /**
     * 设置邮件信息
     * @return Json
     */
    public function setMailInfo()
    {
        $params = $this->postData();
        $result = WebSetService::setMailInfo($params);
        if(true === $result) {
            return $this->success([], '设置成功');
        } else {
            return $this->error(WebSetService::getError());
        }
    }

    /**
     * 获取上传信息
     * @return Json
     */
    public function getUploadInfo()
    {
        $result = WebSetService::getUploadInfo();
        return $this->data($result);
    }

    /**
     * 设置上传信息
     * @return Json
     */
    public function setUploadInfo()
    {
        $params = $this->postData();
        $result = WebSetService::setUploadInfo($params);
        if(true === $result) {
            return $this->success([], '设置成功');
        } else {
            return $this->error(WebSetService::getError());
        }
    }
}